<template>
<div class="hello">
  <input type="button"
      value="打开摄像头"
      @click="doClick">
</div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data() {
    return {}
  },
  methods: {
    doClick() {
      var IntentMana = plus.android.importClass('android.content.Intent')
      var MediaStore = plus.android.importClass('android.provider.MediaStore')
      var App = plus.android.runtimeMainActivity()
      var Uri = plus.android.importClass('android.net.Uri')
      var FILE = plus.android.importClass('java.io.File')
      var intent = new IntentMana(MediaStore.ACTION_IMAGE_CAPTURE)
      var vfile = new FILE('/storage/emulated/0/my/test/img.jpg')
      if (!vfile.exists()) {
        var vDirPath = vfile.getParentFile()
        vDirPath.mkdirs()
      } else {
        alert('文件存在!')
      }
      var uri = Uri.fromFile(vfile)
      intent.putExtra(MediaStore.EXTRA_OUTPUT, uri) //
      App.startActivityForResult(intent, 100)
    }
  }
}
</script>

<style scoped>
h1,
h2 {
  font-weight: normal;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  display: inline-block;
  margin: 0 10px;
}

a {
  color: #42b983;
}
</style>
